{% extends 'base.html' %}
{% load widget_tweaks %}

{% block content %}
<div class="container mt-4">
    <h2>{% if form.instance.id %}编辑{% else %}添加{% endif %}课程评价</h2>
    <div class="card mt-3">
        <div class="card-body">
            <form method="post" class="needs-validation" novalidate>
    {% csrf_token %}
    <div class="form-group mb-3">
        <label for="{{ form.class_schedule.id_for_label }}" class="form-label">课程安排</label>
        {{ form.class_schedule|add_class:"form-control" }}
        {% if form.class_schedule.errors %}
            <div class="invalid-feedback d-block">{{ form.class_schedule.errors }}</div>
        {% endif %}
    </div>
    <div class="form-group mb-3">
        <label for="{{ form.evaluation.id_for_label }}" class="form-label">评价等级</label>
        {{ form.evaluation|add_class:"form-control" }}
        {% if form.evaluation.errors %}
            <div class="invalid-feedback d-block">{{ form.evaluation.errors }}</div>
        {% endif %}
    </div>
    <div class="form-group mb-3">
        <label for="{{ form.remark.id_for_label }}" class="form-label">教师备注</label>
        {{ form.remark|add_class:"form-control" }}
        {% if form.remark.errors %}
            <div class="invalid-feedback d-block">{{ form.remark.errors }}</div>
        {% endif %}
    </div>
    <button type="submit" class="btn btn-primary">保存</button>
    <a href="{% url 'core:class_evaluation_list' form.instance.class_schedule.class_info.id|default:1 %}" class="btn btn-outline-secondary ms-2">取消</a>
</form>
        </div>
    </div>
</div>
{% endblock %}